import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// 状态栏和导航栏样式

SystemUiOverlayStyle systemUIDarkLight = const SystemUiOverlayStyle(
  statusBarColor: Colors.transparent,
  statusBarBrightness: Brightness.light, // ios 与Android 相反
  statusBarIconBrightness: Brightness.dark,
  systemNavigationBarColor: Colors.transparent,
  systemNavigationBarIconBrightness: Brightness.light,
);

SystemUiOverlayStyle systemUIDarkDark = const SystemUiOverlayStyle(
  statusBarColor: Colors.transparent,
  statusBarBrightness: Brightness.light,
  statusBarIconBrightness: Brightness.dark,
  systemNavigationBarColor: Colors.transparent,
  systemNavigationBarIconBrightness: Brightness.dark,
);

SystemUiOverlayStyle systemUILightDark = const SystemUiOverlayStyle(
  statusBarColor: Colors.transparent,
  statusBarBrightness: Brightness.dark,
  statusBarIconBrightness: Brightness.light,
  systemNavigationBarColor: Colors.transparent,
  systemNavigationBarIconBrightness: Brightness.dark,
);

SystemUiOverlayStyle systemUILightLight = const SystemUiOverlayStyle(
  statusBarColor: Colors.transparent,
  statusBarBrightness: Brightness.dark,
  statusBarIconBrightness: Brightness.light,
  systemNavigationBarColor: Colors.transparent,
  systemNavigationBarIconBrightness: Brightness.light,
);

class SystemUIStyleCompat extends StatelessWidget {
  SystemUiOverlayStyle value;
  Widget child;
  SystemUIStyleCompat({super.key, required this.value, required this.child});

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle(
        statusBarColor: value.statusBarColor, //android
        statusBarBrightness: value.statusBarBrightness, //ios
        statusBarIconBrightness: value.statusBarIconBrightness,  //android
        systemNavigationBarColor: (value.systemNavigationBarColor == Colors.transparent &&
            value.systemNavigationBarIconBrightness == Brightness.light)
            ? Colors.black
            : Colors.white, //android
        systemNavigationBarIconBrightness: value.systemNavigationBarIconBrightness, //android
      ),
      // value: SystemUiOverlayStyle.dark,
      child: child,
    );
  }
}
